package paint;

import impsoft.scripting.ibot.structs.XY;

import java.awt.FontMetrics;
import java.awt.Graphics;

public class PaintUtils {

	int ShiftNorth(int p, int distance) {
		return p - distance;
	}

	int ShiftSouth(int p, int distance) {
		return p + distance;
	}

	int ShiftEast(int p, int distance) {
		return p + distance;
	}

	int ShiftWest(int p, int distance) {
		return p - distance;
	}

	public XY centerText(String text, Graphics g, int barWidth, int barHeight) {
		FontMetrics fm = g.getFontMetrics();
		java.awt.geom.Rectangle2D rect = fm.getStringBounds(text, g);

		int textHeight = (int) rect.getHeight();
		int textWidth = (int) rect.getWidth();

		int textX = (barWidth - textWidth) / 2;
		int textY = (barHeight - textHeight) / 2 + fm.getAscent();

		return new XY(textX, textY);
	}
}
